package com.example.testanimation.objectanimation;

import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.View;

public class ObjectEvent extends Activity{

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
	}
	
	
	@SuppressLint("NewApi")
	class MyView extends View {

		AnimatorSet animator;
		
		ShapeHolder shape = new ShapeHolder();
		
		public MyView(Context context) {
			super(context);
		}
		
		
		void startAnimation(){
			animator = createAnimation();
			animator.start();
		}


		private AnimatorSet createAnimation() {
			if(animator == null){
				animator = new AnimatorSet();
				
				ObjectAnimator yAnimator = ObjectAnimator.ofFloat(shape, "y", 0,1000f).setDuration(1000);
				ObjectAnimator xAnimator = ObjectAnimator.ofFloat(shape, "x", 0,1000f).setDuration(1000);
				
				animator.playTogether(yAnimator,xAnimator);
				
			}
			return animator;
		}
		
	}
	
}
